﻿<Window x:Class="PDO.FX.App.DataExplorer.ExplorerWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:controls="clr-namespace:PDO.UI.Controls;assembly=PDO.UI.Controls"
    Title="Data Explorer" Height="450" Width="700"  >
    <Grid >
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition />
        </Grid.RowDefinitions>
        
        <Menu Grid.Row="0" Height="22" Name="appMenu" VerticalAlignment="Top" >
            <MenuItem Header="_File" >
                <MenuItem Name="settingsMenuItem" Header="_Settings" Click="settingsMenuItem_Click" />
            </MenuItem>
        </Menu>

        <DockPanel Grid.Row="1"  LastChildFill="True">
            <StackPanel DockPanel.Dock="Top">
                <Grid >
                    <Grid.RowDefinitions>
                        <RowDefinition />
                        <RowDefinition />
                        <RowDefinition />
                        <RowDefinition />
                        <RowDefinition Height="*" />
                    </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto" />
                        <ColumnDefinition Width="*" />
                        <ColumnDefinition Width="Auto" />
                        <ColumnDefinition Width="Auto" />
                    </Grid.ColumnDefinitions>

                    <Label Grid.Column="0" Grid.Row="0" Content="PersistableDataObject Name:"/>
                    
                    
                    
                    <!-- NOTE: IsTextSearchEnabled doesn't work with DataTemplates, need just a pure string list. -->
                    <ComboBox Grid.Column="1" Name="_classCombo" 
                              IsSynchronizedWithCurrentItem="True" 
                              ItemsSource="{Binding Path=ClassInfoList, Mode=OneWay}"  IsTextSearchEnabled="True" >
                        <ComboBox.ItemTemplate>
                            <DataTemplate>
                                <TextBlock Text="{Binding Path=ClassType.Name}" />
                            </DataTemplate>
                        </ComboBox.ItemTemplate>
                    </ComboBox>

                    <Label Grid.Column="0" Grid.Row="1" Content="Queryable Property Name:" />
                    <ComboBox Grid.Column="1" Grid.Row="1" ItemsSource="{Binding Path=ClassInfoList/QueryablePropertyInfoList}" 
                              Name="_propertyInfoCombo"
                              IsTextSearchEnabled="True" >
                        <ComboBox.ItemTemplate>
                            <DataTemplate>
                                <TextBlock Text="{Binding Path=Name}" />
                            </DataTemplate>
                        </ComboBox.ItemTemplate>
                    </ComboBox>

                    <TextBox Grid.Column="1" Grid.Row="2"  Name="_propertyValueTextBox" />

                    <Popup x:Name="popupLinqMethods"  
                           StaysOpen="False" Placement="Bottom" IsOpen="false" 
                           HorizontalAlignment="Left">
                        <Grid >
                            <ListBox x:Name="lstMethodsSelection" MaxHeight="300" MinWidth="200"
                                     ItemsSource="{Binding Path=ClassInfoList/QueryablePropertyNameList, Mode=OneWay}"
                                     ScrollViewer.HorizontalScrollBarVisibility="Hidden" 
                                     ScrollViewer.VerticalScrollBarVisibility="Auto" 
                                     SelectedIndex="0" 
                                     IsTextSearchEnabled="True" 
                            />
                        </Grid>
                    </Popup>


                    <Button Click="loadButton_Click" Grid.Column="2" Grid.Row="2" HorizontalAlignment="Left" IsDefault="True" Name="_loadButton" >Load</Button>
                    <Button Click="_evaluatorButton_Click" Grid.Column="3" Grid.Row="2" HorizontalAlignment="Left" Name="_evaluatorButton" >Evaluator</Button>
                    
                    <Label Grid.Row="2" Content="Property Value:" />
                    <Label Grid.Column="0" Grid.Row="3" Content="Selected Property Path:" />

                    <TextBox  IsReadOnly="True" Grid.Column="1" Grid.Row="3" Name="_pathTextBox" Text="{Binding ElementName=dataExplorerControl, Path=SelectedItem.PropertyPath}" />
                </Grid>
            </StackPanel>

            <controls:DataExplorerControl x:Name="dataExplorerControl" />
        
        </DockPanel>
    </Grid>

</Window>
